Popular Searches
Popular Course Categories
Popular Courses

Creating multi-section application navigation

Creating multi-section application navigation

Flutter Navigation & Screens

Creating Multi-Section Application Navigation in Flutter

Multi-section application navigation means designing a Flutter application with multiple major sections such as Home, Products, Orders, Favorites, Profile, Settings, or Dashboard and allowing users to move between them efficiently.

Flutter provides several navigation approaches, including NavigationBar, Navigator, nested Navigator widgets, and Router-based navigation. For simple applications, Navigator is often sufficient, while applications with advanced navigation, deep linking, web URLs, or multiple navigators can use Router-based solutions such as go_router. Flutter Navigation and Routing Documentation


1. What Is Multi-Section Application Navigation?

A multi-section application divides an application into major functional areas. Each section has its own purpose and may contain additional screens.

Example

Application
├── Home
├── Products
│   ├── Product List
│   └── Product Details
├── Orders
│   ├── Order List
│   └── Order Details
├── Favorites
└── Profile
    ├── Edit Profile
    └── Settings

Users can move between the main sections and then navigate deeper into each section.


2. Why Multi-Section Navigation Is Important

  • Organizes large applications into logical sections.
  • Makes important features easier to access.
  • Improves the overall user experience.
  • Separates different areas of application functionality.
  • Allows each section to have its own navigation flow.
  • Makes large applications easier to maintain.
  • Supports scalable application architecture.

3. Common Multi-Section Navigation Patterns

Navigation Pattern Common Use
NavigationBar Primary sections on mobile
NavigationDrawer Many application sections
NavigationRail Tablet and desktop layouts
Navigator Moving between routes/screens
Nested Navigator Independent navigation inside a section
Router Advanced navigation and deep linking

Flutter's Material components include NavigationBar, NavigationDrawer, NavigationRail, and TabBar for different navigation and organization scenarios. Flutter Material Components


4. NavigationBar for Primary Sections

NavigationBar is the Material 3 component designed for persistent navigation between primary destinations in an application. It uses NavigationDestination widgets and a selectedIndex to identify the active destination. Flutter NavigationBar API

NavigationBar(
  selectedIndex: selectedIndex,
  onDestinationSelected: (index) {
    setState(() {
      selectedIndex = index;
    });
  },
  destinations: const [
    NavigationDestination(
      icon: Icon(Icons.home_outlined),
      selectedIcon: Icon(Icons.home),
      label: 'Home',
    ),
    NavigationDestination(
      icon: Icon(Icons.shopping_bag_outlined),
      selectedIcon: Icon(Icons.shopping_bag),
      label: 'Products',
    ),
    NavigationDestination(
      icon: Icon(Icons.person_outline),
      selectedIcon: Icon(Icons.person),
      label: 'Profile',
    ),
  ],
)

5. Basic Multi-Section Application

The following example creates a simple application with four primary sections:

  • Home
  • Products
  • Orders
  • Profile
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: const MainScreen(),
    );
  }
}

class MainScreen extends StatefulWidget {
  const MainScreen({super.key});

  @override
  State createState() => _MainScreenState();
}

class _MainScreenState extends State {
  int selectedIndex = 0;

  final List sections = const [
    HomeScreen(),
    ProductsScreen(),
    OrdersScreen(),
    ProfileScreen(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('My Application'),
      ),
      body: sections[selectedIndex],
      bottomNavigationBar: NavigationBar(
        selectedIndex: selectedIndex,
        onDestinationSelected: (index) {
          setState(() {
            selectedIndex = index;
          });
        },
        destinations: const [
          NavigationDestination(
            icon: Icon(Icons.home_outlined),
            selectedIcon: Icon(Icons.home),
            label: 'Home',
          ),
          NavigationDestination(
            icon: Icon(Icons.shopping_bag_outlined),
            selectedIcon: Icon(Icons.shopping_bag),
            label: 'Products',
          ),
          NavigationDestination(
            icon: Icon(Icons.receipt_long_outlined),
            selectedIcon: Icon(Icons.receipt_long),
            label: 'Orders',
          ),
          NavigationDestination(
            icon: Icon(Icons.person_outline),
            selectedIcon: Icon(Icons.person),
            label: 'Profile',
          ),
        ],
      ),
    );
  }
}

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return const Center(
      child: Text('Home'),
    );
  }
}

class ProductsScreen extends StatelessWidget {
  const ProductsScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return const Center(
      child: Text('Products'),
    );
  }
}

class OrdersScreen extends StatelessWidget {
  const OrdersScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return const Center(
      child: Text('Orders'),
    );
  }
}

class ProfileScreen extends StatelessWidget {
  const ProfileScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return const Center(
      child: Text('Profile'),
    );
  }
}

6. Understanding selectedIndex

The selectedIndex variable identifies which primary section is currently active.

int selectedIndex = 0;

For example:

Index Section
0 Home
1 Products
2 Orders
3 Profile

When the user selects Products:

setState(() {
  selectedIndex = 1;
});

The body can then display:

body: sections[selectedIndex]

7. Application Navigation Structure

                    Application
                        |
             ┌──────────┼──────────┐
             ↓          ↓          ↓
           Home      Products     Profile
                        |
                        ↓
                  Product List
                        |
                        ↓
                 Product Details
                        |
                        ↓
                     Cart

This structure separates primary navigation from secondary navigation.


8. Primary Navigation vs Secondary Navigation

Type Example Typical Flutter Approach
Primary Navigation Home, Products, Orders, Profile NavigationBar
Secondary Navigation Product Details Navigator.push()
Sub-flow Navigation Checkout steps Nested Navigator
Deep Navigation Direct product URL Router/go_router

9. Navigating from a Section to a Detail Screen

A primary section can open a secondary screen using Navigator.push().

class ProductsScreen extends StatelessWidget {
  const ProductsScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: ElevatedButton(
        onPressed: () {
          Navigator.push(
            context,
            MaterialPageRoute(
              builder: (context) =>
                  const ProductDetailsScreen(),
            ),
          );
        },
        child: const Text('Open Product Details'),
      ),
    );
  }
}

class ProductDetailsScreen extends StatelessWidget {
  const ProductDetailsScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Product Details'),
      ),
      body: const Center(
        child: Text('Product Details'),
      ),
    );
  }
}

Flutter's Navigator manages routes as a stack, with push() adding a route and pop() removing the current route. Flutter Navigator API


10. Passing Data Between Sections and Screens

Multi-section applications often need to pass information to secondary screens.

Navigator.push(
  context,
  MaterialPageRoute(
    builder: (context) => ProductDetailsScreen(
      productName: 'Laptop',
      price: 55000,
    ),
  ),
);

Destination screen:

class ProductDetailsScreen extends StatelessWidget {
  final String productName;
  final double price;

  const ProductDetailsScreen({
    super.key,
    required this.productName,
    required this.price,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(productName),
      ),
      body: Column(
        children: [
          Text('Product: $productName'),
          Text('Price: ₹$price'),
        ],
      ),
    );
  }
}

11. Passing a Model Object

For larger applications, passing a model object keeps related information together.

class Product {
  final int id;
  final String name;
  final double price;
  final String category;

  const Product({
    required this.id,
    required this.name,
    required this.price,
    required this.category,
  });
}

Pass the product:

Navigator.push(
  context,
  MaterialPageRoute(
    builder: (context) =>
        ProductDetailsScreen(
      product: product,
    ),
  ),
);

Receive the product:

class ProductDetailsScreen extends StatelessWidget {
  final Product product;

  const ProductDetailsScreen({
    super.key,
    required this.product,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(product.name),
      ),
      body: Padding(
        padding: const EdgeInsets.all(20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text('ID: ${product.id}'),
            Text('Name: ${product.name}'),
            Text('Category: ${product.category}'),
            Text('Price: ₹${product.price}'),
          ],
        ),
      ),
    );
  }
}

12. Complete Multi-Section Shopping Application Example

The following example combines primary navigation, product data, and detail navigation.

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class Product {
  final int id;
  final String name;
  final double price;

  const Product({
    required this.id,
    required this.name,
    required this.price,
  });
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: const MainScreen(),
    );
  }
}

class MainScreen extends StatefulWidget {
  const MainScreen({super.key});

  @override
  State createState() => _MainScreenState();
}

class _MainScreenState extends State {
  int selectedIndex = 0;

  final List screens = const [
    HomeScreen(),
    ProductsScreen(),
    OrdersScreen(),
    ProfileScreen(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Shopping App'),
      ),
      body: screens[selectedIndex],
      bottomNavigationBar: NavigationBar(
        selectedIndex: selectedIndex,
        onDestinationSelected: (index) {
          setState(() {
            selectedIndex = index;
          });
        },
        destinations: const [
          NavigationDestination(
            icon: Icon(Icons.home_outlined),
            selectedIcon: Icon(Icons.home),
            label: 'Home',
          ),
          NavigationDestination(
            icon: Icon(Icons.shopping_bag_outlined),
            selectedIcon: Icon(Icons.shopping_bag),
            label: 'Products',
          ),
          NavigationDestination(
            icon: Icon(Icons.receipt_long_outlined),
            selectedIcon: Icon(Icons.receipt_long),
            label: 'Orders',
          ),
          NavigationDestination(
            icon: Icon(Icons.person_outline),
            selectedIcon: Icon(Icons.person),
            label: 'Profile',
          ),
        ],
      ),
    );
  }
}

class HomeScreen extends StatelessWidget {
  const HomeScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return const Center(
      child: Text(
        'Welcome to the Shopping App',
        style: TextStyle(fontSize: 22),
      ),
    );
  }
}

class ProductsScreen extends StatelessWidget {
  const ProductsScreen({super.key});

  final List products = const [
    Product(
      id: 1,
      name: 'Laptop',
      price: 55000,
    ),
    Product(
      id: 2,
      name: 'Smartphone',
      price: 30000,
    ),
    Product(
      id: 3,
      name: 'Headphones',
      price: 3000,
    ),
  ];

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemCount: products.length,
      itemBuilder: (context, index) {
        final product = products[index];

        return Card(
          margin: const EdgeInsets.all(8),
          child: ListTile(
            title: Text(product.name),
            subtitle: Text('₹${product.price}'),
            trailing: const Icon(
              Icons.arrow_forward_ios,
            ),
            onTap: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                  builder: (context) =>
                      ProductDetailsScreen(
                    product: product,
                  ),
                ),
              );
            },
          ),
        );
      },
    );
  }
}

class ProductDetailsScreen extends StatelessWidget {
  final Product product;

  const ProductDetailsScreen({
    super.key,
    required this.product,
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Product Details'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(20),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              product.name,
              style: const TextStyle(
                fontSize: 28,
                fontWeight: FontWeight.bold,
              ),
            ),
            const SizedBox(height: 15),
            Text('Product ID: ${product.id}'),
            Text(
              'Price: ₹${product.price}',
              style: const TextStyle(fontSize: 20),
            ),
            const SizedBox(height: 25),
            ElevatedButton(
              onPressed: () {
                ScaffoldMessenger.of(context).showSnackBar(
                  const SnackBar(
                    content: Text('Product added to cart'),
                  ),
                );
              },
              child: const Text('Add to Cart'),
            ),
          ],
        ),
      ),
    );
  }
}

class OrdersScreen extends StatelessWidget {
  const OrdersScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return const Center(
      child: Text(
        'Orders',
        style: TextStyle(fontSize: 25),
      ),
    );
  }
}

class ProfileScreen extends StatelessWidget {
  const ProfileScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return const Center(
      child: Text(
        'Profile',
        style: TextStyle(fontSize: 25),
      ),
    );
  }
}

13. Independent Navigation Inside Each Section

In a larger application, each primary section may need its own navigation history. For example, the Products section can contain:

Products
   ↓
Product List
   ↓
Product Details
   ↓
Reviews

At the same time, the Profile section can maintain:

Profile
   ↓
Edit Profile
   ↓
Change Password

Flutter supports nested navigation by placing a separate Navigator inside a section. The official Flutter nested-navigation recipe demonstrates using a nested Navigator to manage a local multi-page flow. Flutter Nested Navigation


14. Why Use Nested Navigation?

  • Each section can maintain its own navigation history.
  • Navigation logic becomes localized to the relevant section.
  • Complex workflows do not have to be managed entirely by the top-level Navigator.
  • Users can move deeply inside one section without losing the state of other sections.
  • It is useful for checkout, onboarding, setup flows, and multi-step processes.

15. Basic Nested Navigator Structure

Main Navigator
│
├── Home
│
├── Products
│   └── Products Navigator
│       ├── Product List
│       ├── Product Details
│       └── Reviews
│
├── Orders
│   └── Orders Navigator
│       ├── Order List
│       └── Order Details
│
└── Profile
    └── Profile Navigator
        ├── Profile
        ├── Edit Profile
        └── Settings

16. Basic Nested Navigator Example

class ProductsSection extends StatelessWidget {
  const ProductsSection({super.key});

  @override
  Widget build(BuildContext context) {
    return Navigator(
      onGenerateRoute: (settings) {
        return MaterialPageRoute(
          builder: (context) =>
              const ProductListScreen(),
        );
      },
    );
  }
}

A more advanced implementation can define several local routes and control them using a nested Navigator. Flutter's official nested-navigation example uses a GlobalKey to control the nested Navigator. Flutter Nested Navigation Recipe


17. Nested Navigator with GlobalKey

final GlobalKey navigatorKey =
    GlobalKey();

The key can be used to access the nested Navigator's state:

navigatorKey.currentState!.push(
  MaterialPageRoute(
    builder: (context) =>
        const ProductDetailsScreen(),
  ),
);

This approach is useful when navigation needs to be controlled from the surrounding section rather than directly from the child widget.


18. Preserving Navigation State Between Sections

Suppose the user opens:

Products
   ↓
Product Details
   ↓
Reviews

Then switches to Profile and later returns to Products. In a carefully designed multi-Navigator architecture, the Products section can preserve its own navigation history instead of starting again from the Product List.

This is one reason nested navigation can be useful for complex multi-section applications.


19. Using Stack and Offstage for Persistent Section State

A common advanced pattern is to keep each section in a Stack and use Offstage to hide inactive sections while keeping them mounted.

Stack(
  children: [
    Offstage(
      offstage: selectedIndex != 0,
      child: const HomeSection(),
    ),
    Offstage(
      offstage: selectedIndex != 1,
      child: const ProductsSection(),
    ),
    Offstage(
      offstage: selectedIndex != 2,
      child: const OrdersSection(),
    ),
    Offstage(
      offstage: selectedIndex != 3,
      child: const ProfileSection(),
    ),
  ],
)

Flutter's NavigationBar API documentation includes an example where destination pages have their own local Navigator and are organized in a Stack so that navigation state can be maintained while switching destinations. NavigationBar API Example


20. Navigation Drawer for Multiple Sections

When an application has many sections, a Navigation Drawer can be more suitable than a bottom navigation bar.

Scaffold(
  drawer: Drawer(
    child: ListView(
      children: [
        const DrawerHeader(
          child: Text('My App'),
        ),
        ListTile(
          leading: const Icon(Icons.home),
          title: const Text('Home'),
          onTap: () {},
        ),
        ListTile(
          leading: const Icon(Icons.shopping_bag),
          title: const Text('Products'),
          onTap: () {},
        ),
        ListTile(
          leading: const Icon(Icons.settings),
          title: const Text('Settings'),
          onTap: () {},
        ),
      ],
    ),
  ),
  body: const HomeScreen(),
)

Navigation drawers are useful when there are more destinations than are practical for a bottom navigation component.


21. NavigationRail for Larger Screens

For tablets, desktop applications, and larger layouts, a side navigation component can provide more usable space.

Row(
  children: [
    NavigationRail(
      selectedIndex: selectedIndex,
      onDestinationSelected: (index) {
        setState(() {
          selectedIndex = index;
        });
      },
      destinations: const [
        NavigationRailDestination(
          icon: Icon(Icons.home),
          label: Text('Home'),
        ),
        NavigationRailDestination(
          icon: Icon(Icons.shopping_bag),
          label: Text('Products'),
        ),
        NavigationRailDestination(
          icon: Icon(Icons.person),
          label: Text('Profile'),
        ),
      ],
    ),
    Expanded(
      child: screens[selectedIndex],
    ),
  ],
)

22. Responsive Multi-Section Navigation

A modern Flutter application can change its navigation pattern depending on the available screen width.

if (width < 600) {
  return NavigationBar(
    selectedIndex: selectedIndex,
    onDestinationSelected: onDestinationSelected,
    destinations: destinations,
  );
}

return NavigationRail(
  selectedIndex: selectedIndex,
  onDestinationSelected: onDestinationSelected,
  destinations: railDestinations,
);

Possible Layout Strategy

Device Navigation
Mobile NavigationBar
Tablet NavigationRail
Desktop NavigationRail or NavigationDrawer

23. Multi-Section Navigation with Data

Each section can have its own data model.

Home
 └── User summary

Products
 └── List

Orders
 └── List

Profile
 └── User

When a user selects a product:

Product List
     |
     | Product object
     ↓
Product Details

When a user selects an order:

Order List
     |
     | Order object
     ↓
Order Details

24. Passing Data from One Section to Another

Sometimes information needs to be shared between primary sections. For example, a product selected in Products may be added to Cart.

Products
   |
   | Add Product
   ↓
Shared Application State
   |
   ↓
Cart

For application-wide information such as cart contents, authentication state, or user preferences, a state-management or application-state architecture may be more suitable than passing large objects through multiple navigation levels.


25. Multi-Section Navigation with Cart Example

class CartItem {
  final Product product;
  final int quantity;

  const CartItem({
    required this.product,
    required this.quantity,
  });
}

A selected product can be added to application state:

void addToCart(Product product) {
  cartItems.add(
    CartItem(
      product: product,
      quantity: 1,
    ),
  );
}

The Cart section can then display the shared cart information.


26. Navigation Stack

The Navigator manages routes using a stack-like structure.

Initial:
[Home]

Push Products:
[Home, Products]

Push Product Details:
[Home, Products, Product Details]

Pop:
[Home, Products]

Pop:
[Home]

Flutter's Navigator documentation describes the Navigator as a widget that manages routes using stack discipline. Flutter Navigator Class


27. Navigator.push()

Navigator.push() adds a new route to the current Navigator stack.

Navigator.push(
  context,
  MaterialPageRoute(
    builder: (context) =>
        const DetailsScreen(),
  ),
);

28. Navigator.pop()

Navigator.pop() removes the current route and returns to the previous route.

Navigator.pop(context);

It can also return data:

Navigator.pop(context, 'Selected Product');

29. Returning Data to a Multi-Section Screen

final result = await Navigator.push(
  context,
  MaterialPageRoute(
    builder: (context) =>
        const SelectionScreen(),
  ),
);

if (!mounted) return;

if (result != null) {
  print('Selected: $result');
}

This is useful for selection screens, edit screens, filters, and forms.


30. Deep Linking in Multi-Section Applications

Deep linking allows a URL or external link to open a specific location inside the application. Flutter supports deep links on Android, iOS, and web. Flutter Deep Linking Documentation

Example

myapp.com/products/101

This link could represent:

Application
   ↓
Products
   ↓
Product Details
   ↓
Product ID = 101

Deep linking is particularly useful for e-commerce, news, social media, and web applications.


31. Router-Based Navigation

Flutter provides the Router API for applications with advanced navigation requirements. Flutter's current navigation documentation recommends considering a routing package such as go_router for complex navigation and deep-linking scenarios. Flutter Navigation and Routing

A router-based structure may look like:

/
├── /home
├── /products
│   ├── /products/101
│   └── /products/102
├── /orders
└── /profile

32. go_router for Large Applications

go_router is a routing package maintained by the Flutter team and is designed to simplify routing scenarios such as nested navigation and deep linking.

A basic example can look like:

final router = GoRouter(
  routes: [
    GoRoute(
      path: '/',
      builder: (context, state) =>
          const HomeScreen(),
    ),
    GoRoute(
      path: '/products',
      builder: (context, state) =>
          const ProductsScreen(),
    ),
    GoRoute(
      path: '/profile',
      builder: (context, state) =>
          const ProfileScreen(),
    ),
  ],
);

Navigation can then use:

context.go('/products');

For complex applications with direct URLs and multiple Navigator widgets, Flutter's official navigation guidance recommends a Router-based approach or a routing package such as go_router. Flutter Navigation Documentation


33. Named Routes

Named routes are another Flutter navigation mechanism, but current Flutter documentation does not recommend them for most new applications. For new applications, Flutter recommends considering go_router or using Navigator with MaterialPageRoute. Flutter Navigation Guidance

A legacy named-route example is:

MaterialApp(
  routes: {
    '/': (context) => const HomeScreen(),
    '/products': (context) => const ProductsScreen(),
    '/profile': (context) => const ProfileScreen(),
  },
)

Navigation:

Navigator.pushNamed(
  context,
  '/products',
);

34. Multi-Section Navigation with a Drawer

For an administration panel or enterprise application, a Navigation Drawer can provide access to many sections.

Dashboard
Users
Products
Orders
Reports
Settings
Help

Example:

Drawer(
  child: ListView(
    children: [
      const DrawerHeader(
        child: Text('Admin Panel'),
      ),
      ListTile(
        leading: const Icon(Icons.dashboard),
        title: const Text('Dashboard'),
        onTap: () {
          Navigator.pop(context);
        },
      ),
      ListTile(
        leading: const Icon(Icons.people),
        title: const Text('Users'),
        onTap: () {
          Navigator.pop(context);
        },
      ),
      ListTile(
        leading: const Icon(Icons.inventory),
        title: const Text('Products'),
        onTap: () {
          Navigator.pop(context);
        },
      ),
      ListTile(
        leading: const Icon(Icons.settings),
        title: const Text('Settings'),
        onTap: () {
          Navigator.pop(context);
        },
      ),
    ],
  ),
)

35. Multi-Section Admin Panel Navigation

Admin Application
│
├── Dashboard
│   ├── Statistics
│   └── Charts
│
├── Users
│   ├── User List
│   └── User Details
│
├── Products
│   ├── Product List
│   ├── Add Product
│   └── Edit Product
│
├── Orders
│   ├── Order List
│   └── Order Details
│
└── Settings
    ├── General
    └── Security

This structure can be implemented using a NavigationRail, NavigationDrawer, Router, or a combination of these depending on the target device and application complexity.


36. Nested Navigation for a Checkout Flow

A checkout process is a good example of a local navigation flow.

Cart
 ↓
Address
 ↓
Payment
 ↓
Review
 ↓
Confirmation

Instead of adding all checkout routes to the application's global Navigator, a nested Navigator can manage the checkout flow.

Main Application Navigator
        |
        └── Checkout Flow
              |
              ├── Address
              ├── Payment
              ├── Review
              └── Confirmation

Flutter's nested-navigation recipe uses the same concept for a multi-step device setup flow, keeping the local flow under a nested Navigator. Flutter Nested Navigation Recipe


37. Handling Back Navigation

Back navigation should normally return the user to the previous screen in the active navigation stack.

Product List
     ↓
Product Details
     ↓
Reviews

Pressing back from Reviews:

Reviews
   ↓
Product Details

Pressing back again:

Product Details
   ↓
Product List

Nested Navigators can manage their own local back stack before the application exits the larger section or flow.


38. Root Navigator vs Nested Navigator

Flutter's Navigator.of(context) normally returns the closest Navigator surrounding the given context. Setting rootNavigator: true accesses the furthest/root Navigator. Navigator.of API

Navigator.of(context).push(
  MaterialPageRoute(
    builder: (context) =>
        const DetailsScreen(),
  ),
);

To access the root Navigator:

Navigator.of(
  context,
  rootNavigator: true,
).push(
  MaterialPageRoute(
    builder: (context) =>
        const DetailsScreen(),
  ),
);

39. Choosing the Right Navigation Architecture

Application Size Suggested Approach
Small app NavigationBar + Navigator
Medium app NavigationBar + section navigation
Complex mobile app Multiple Navigators or Router-based architecture
Web app with URLs Router/go_router
App with deep links Router/go_router
Complex multi-step flow Nested Navigator
Large desktop/tablet app NavigationRail/Drawer + Router

40. Common Mistakes

Mistake 1: Putting Every Screen Directly in Bottom Navigation

Bottom navigation should generally represent primary destinations, not every detail page.

Mistake 2: Using Too Many Bottom Navigation Items

A bottom navigation component is intended for a small set of primary destinations. When an application has many sections, consider a drawer or another navigation pattern.

Mistake 3: Losing Section State

Recreating every section unnecessarily can reset scroll positions, forms, and local state. For applications that require persistent section state, consider keeping destinations mounted or using nested navigation.

Mistake 4: Using Named Routes for Every New Application

Current Flutter documentation does not recommend named routes for most new applications because of limitations around advanced navigation and deep-link handling.

Mistake 5: Mixing Navigation Responsibilities

Keep primary navigation, local section navigation, and global application routing conceptually separate.


41. Best Practices

  • Use primary navigation for major application sections.
  • Use NavigationBar for Material 3 mobile applications.
  • Use NavigationRail or NavigationDrawer when the screen size or number of destinations makes them more appropriate.
  • Use Navigator.push() for detail screens.
  • Use model objects for strongly typed data passing.
  • Use nested Navigators for independent multi-step flows.
  • Keep navigation logic close to the feature it controls.
  • Use Router or go_router for advanced deep linking and complex navigation.
  • Design navigation responsively for mobile, tablet, and desktop.
  • Keep primary destinations limited to the most important sections.
  • Test Android back navigation and web browser back/forward behavior when applicable.

42. Responsive Navigation Architecture

                  Flutter Application
                         |
             ┌───────────┴───────────┐
             ↓                       ↓
        Small Screen            Large Screen
             |                       |
       NavigationBar          NavigationRail
             |                       |
             └───────────┬───────────┘
                         ↓
                Section Navigator
                         |
          ┌──────────────┼──────────────┐
          ↓              ↓              ↓
       Home          Products         Profile
                         |
                         ↓
                  Nested Navigation
                         |
                  Product Details

43. Real-World Social Media Application

A social media application can contain:

Social App
├── Home Feed
├── Search
├── Create Post
├── Notifications
└── Profile

Profile can have its own local navigation:

Profile
├── Posts
├── Followers
├── Following
├── Edit Profile
└── Settings

This is an example of primary navigation combined with secondary and nested navigation.


44. Real-World Education Application

Education App
├── Home
├── Courses
│   ├── Course Details
│   ├── Lessons
│   └── Quiz
├── Progress
└── Profile

Course navigation can be managed as a local flow:

Course Details
      ↓
Lesson
      ↓
Next Lesson
      ↓
Quiz
      ↓
Result

45. Multi-Section Navigation Flow

                         APP
                          |
       ┌──────────────────┼──────────────────┐
       ↓                  ↓                  ↓
     HOME              PRODUCTS           PROFILE
       |                  |                  |
       |                  ↓                  ↓
       |             PRODUCT LIST       EDIT PROFILE
       |                  |                  |
       |                  ↓                  ↓
       |           PRODUCT DETAILS       SETTINGS
       |                  |
       |                  ↓
       |                CART
       |
       ↓
    DASHBOARD

46. Practical Project Structure

A scalable Flutter project can organize navigation-related files separately from individual features.

lib/
├── main.dart
├── app/
│   ├── app.dart
│   └── router.dart
├── navigation/
│   ├── navigation_shell.dart
│   └── navigation_items.dart
├── features/
│   ├── home/
│   │   ├── home_screen.dart
│   │   └── home_widgets.dart
│   ├── products/
│   │   ├── product_list_screen.dart
│   │   ├── product_details_screen.dart
│   │   └── product_model.dart
│   ├── orders/
│   │   ├── order_list_screen.dart
│   │   └── order_details_screen.dart
│   └── profile/
│       ├── profile_screen.dart
│       ├── edit_profile_screen.dart
│       └── settings_screen.dart

This type of organization helps separate navigation infrastructure from individual application features.


47. Mini Project: Multi-Section Flutter App

Project Requirements

  1. Create a Flutter application.
  2. Create Home, Products, Orders, Favorites, and Profile sections.
  3. Use NavigationBar for primary navigation.
  4. Create a Product model.
  5. Display products in a ListView.
  6. Open Product Details using Navigator.push().
  7. Pass the Product object to Product Details.
  8. Create an Orders section with order objects.
  9. Open Order Details from the Orders section.
  10. Create an Edit Profile screen.
  11. Return updated profile information using Navigator.pop().
  12. Add a Settings screen.
  13. Use nested navigation for a multi-step checkout flow.
  14. Make navigation responsive for mobile and tablet layouts.

48. Interview Questions

  1. What is multi-section navigation in Flutter?
  2. What is the purpose of NavigationBar?
  3. What is the difference between primary and secondary navigation?
  4. How does selectedIndex work?
  5. What is NavigationDestination?
  6. When should you use Navigator.push()?
  7. What is a nested Navigator?
  8. Why would an application need multiple Navigator widgets?
  9. What is the difference between a root Navigator and a nested Navigator?
  10. What is the purpose of Navigator.of(context, rootNavigator: true)?
  11. How can you preserve navigation state between sections?
  12. When should you use NavigationRail instead of NavigationBar?
  13. When is a NavigationDrawer useful?
  14. What is deep linking?
  15. Why are Router-based solutions useful for complex applications?
  16. Why are named routes not recommended for most new Flutter applications?
  17. How can you pass data from a primary section to a details screen?
  18. How can a nested Navigator manage a multi-step flow?
  19. How would you design navigation for a large Flutter web application?
  20. How can navigation be made responsive?

49. Practical Exercise

Create a complete multi-section Flutter application with the following architecture:

                         My App
                           |
       ┌───────────────────┼───────────────────┐
       ↓                   ↓                   ↓
      Home              Products             Profile
                           |                   |
                           ↓                   ↓
                     Product List        Edit Profile
                           |
                           ↓
                    Product Details
                           |
                           ↓
                         Cart

Requirements

  • Use NavigationBar.
  • Create at least four primary sections.
  • Create at least three Product objects.
  • Display products using ListView.
  • Open a details page when a product is selected.
  • Pass the Product object to the details page.
  • Implement a Profile section.
  • Implement an Edit Profile page.
  • Return edited information to the Profile screen.
  • Create a nested checkout flow.
  • Test back navigation.
  • Test the application on different screen sizes.

50. Quick Revision

  • Multi-section navigation divides an application into major functional areas.
  • NavigationBar is useful for primary mobile destinations.
  • NavigationDestination represents an item inside NavigationBar.
  • selectedIndex identifies the active destination.
  • Navigator.push() opens a secondary route.
  • Navigator.pop() returns to the previous route.
  • Constructor parameters are useful for passing data.
  • Model objects are useful for structured application data.
  • Nested Navigators are useful for independent navigation flows.
  • NavigationRail and NavigationDrawer can be useful for larger screens or more destinations.
  • Router-based navigation is useful for advanced routing and deep links.
  • Current Flutter documentation recommends considering go_router or Navigator with MaterialPageRoute instead of named routes for most new applications.

51. Key Takeaways

Creating multi-section application navigation is an important Flutter skill for building real-world applications. A well-designed application should separate primary navigation from detail navigation and complex local flows.

A typical architecture can be summarized as:

Primary Navigation
        ↓
Application Section
        ↓
Section Navigation
        ↓
Detail Screen
        ↓
Nested Flow if Required
        ↓
Return to Section

For simple applications, NavigationBar combined with Navigator is often enough. For larger applications with independent section histories, nested Navigators can provide better separation. For applications requiring complex URLs, deep linking, browser history, or advanced routing, Router-based navigation or go_router can be considered. Official Flutter Navigation Documentation


52. Official Flutter Resources


53. Flutter Training Resources

For structured Flutter learning, practical development, and course-related information, visit the following resources:

whatsapp